/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package co.com.entidades;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

/**
 *
 * @author 839398
 */
@Entity
@Table(name = "tbl_insumo_actividad")
@NamedQueries({
    @NamedQuery(name = "TblInsumoActividad.findAll", query = "SELECT t FROM TblInsumoActividad t"),
    @NamedQuery(name = "TblInsumoActividad.findByActividad", query = "SELECT t FROM TblInsumoActividad t WHERE t.tblInsumoActividadPK.actividad = :actividad"),
    @NamedQuery(name = "TblInsumoActividad.findByInsumo", query = "SELECT t FROM TblInsumoActividad t WHERE t.tblInsumoActividadPK.insumo = :insumo"),
    @NamedQuery(name = "TblInsumoActividad.findByCantidad", query = "SELECT t FROM TblInsumoActividad t WHERE t.cantidad = :cantidad"),
    @NamedQuery(name = "TblInsumoActividad.findByValor", query = "SELECT t FROM TblInsumoActividad t WHERE t.valor = :valor"),
    @NamedQuery(name = "TblInsumoActividad.findByTotal", query = "SELECT t FROM TblInsumoActividad t WHERE t.total = :total")})
public class TblInsumoActividad implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @EmbeddedId
    protected TblInsumoActividadPK tblInsumoActividadPK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "cantidad")
    private short cantidad;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "valor")
    private BigDecimal valor;
    @Column(name = "total")
    private BigDecimal total;
    @JoinColumn(name = "insumo", referencedColumnName = "cod_insumo", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private TblInsumos tblInsumos;
    @JoinColumn(name = "actividad", referencedColumnName = "cod_actividad", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private TblActividad tblActividad;

    public TblInsumoActividad() {
    }

    public TblInsumoActividad(TblInsumoActividadPK tblInsumoActividadPK) {
        this.tblInsumoActividadPK = tblInsumoActividadPK;
    }

    public TblInsumoActividad(TblInsumoActividadPK tblInsumoActividadPK, short cantidad, BigDecimal valor) {
        this.tblInsumoActividadPK = tblInsumoActividadPK;
        this.cantidad = cantidad;
        this.valor = valor;
    }

    public TblInsumoActividad(int actividad, int insumo) {
        this.tblInsumoActividadPK = new TblInsumoActividadPK(actividad, insumo);
    }

    public TblInsumoActividadPK getTblInsumoActividadPK() {
        return tblInsumoActividadPK;
    }

    public void setTblInsumoActividadPK(TblInsumoActividadPK tblInsumoActividadPK) {
        this.tblInsumoActividadPK = tblInsumoActividadPK;
    }

    public short getCantidad() {
        return cantidad;
    }

    public void setCantidad(short cantidad) {
        this.cantidad = cantidad;
    }

    public BigDecimal getValor() {
        return valor;
    }

    public void setValor(BigDecimal valor) {
        this.valor = valor;
    }

    public BigDecimal getTotal() {
        return total;
    }

    public void setTotal(BigDecimal total) {
        this.total = total;
    }

    public TblInsumos getTblInsumos() {
        return tblInsumos;
    }

    public void setTblInsumos(TblInsumos tblInsumos) {
        this.tblInsumos = tblInsumos;
    }

    public TblActividad getTblActividad() {
        return tblActividad;
    }

    public void setTblActividad(TblActividad tblActividad) {
        this.tblActividad = tblActividad;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tblInsumoActividadPK != null ? tblInsumoActividadPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TblInsumoActividad)) {
            return false;
        }
        TblInsumoActividad other = (TblInsumoActividad) object;
        if ((this.tblInsumoActividadPK == null && other.tblInsumoActividadPK != null) || (this.tblInsumoActividadPK != null && !this.tblInsumoActividadPK.equals(other.tblInsumoActividadPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "" + tblInsumoActividadPK;
    }
    
}
